from django.db import models


class Author(models.Model):
    name = models.CharField('姓名', max_length=11, null=False)
    age = models.IntegerField('年龄', default=1)
    gender = models.CharField('性别', max_length=5, default='男')
    # email = models.EmailField('邮箱', null=True)


class Book(models.Model):
    title = models.CharField("书名", max_length=50, default='', unique=True)  # CharField 必须设置max_length
    pub = models.CharField("出版社", max_length=100, default='', null=False)
    price = models.DecimalField('图书定价', max_digits=7, decimal_places=2)
    market_price = models.DecimalField('图书零售价', max_digits=7, decimal_places=2, default=0.00)
    is_delete = models.BooleanField('是否被删除', default=False)

    authors = models.ManyToManyField(Author)



